package market;

import java.math.BigDecimal;

/**
 * 水果类
 */
public class Fruit {
    private String name;
    private BigDecimal price;
    private int weight;
    private DiscountProxy discountProxy;

    public Fruit(int weight, BigDecimal price, String name, DiscountProxy discountProxy) throws Exception {
        this.name = name;
        this.weight = weight;
        this.price = price;
        this.discountProxy = discountProxy;
        this.check();
    }
    //检测数据合法性
    public void check() throws Exception {
        if(!(this.weight >=0)){
            throw new Exception("重量必须大于0");
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public DiscountProxy getDiscountProxy() {
        return discountProxy;
    }

    public void setDiscountProxy(DiscountProxy discountProxy) {
        this.discountProxy = discountProxy;
    }



}
